<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<p:dialog xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" 
	xmlns:of="http://omnifaces.org/functions"
	modal="true" width="660" height="400" resizable="false" 
	widgetVar="dialogFormOrdemServico" id="formDialogOrdemServico"
	appendToBody="true">

	<link type="text/css" rel="stylesheet" href="../../resources/css/style.css" />
	
	<style>
			.panel300 {
				width: 320px;
			}
			.panel100 {
				width: 100px;
			}
		</style>
	
	
	<f:facet name="header">
		<h:outputText value="Gerar Ordem de Serviço"/>
	</f:facet>
	
	<h:form prependId="false" id="formOrdemServico">
		<div style="margin-left:5%;">
			<h:panelGrid columns="3" columnClasses="panel300, panel100">			
				<h:outputText value="Cliente" style="font-weight:bold;" />				
				<h:outputText value="Data" style="font-weight:bold;"/>
				<h:outputText value="Valor total dos seviços" style="font-weight:bold;"/>
								
				<h:outputText value="#{of:abbreviate(agendamentoBean.currentOrdemServico.cliente.nome, 55)}"/>				
				<h:outputText style="width:100px;" value="#{agendamentoBean.currentOrdemServico.data}">
					<f:convertDateTime pattern="dd/MM/yyyy" />
				</h:outputText>
				<h:outputText value="#{agendamentoBean.currentOrdemServico.valor}">
					<f:convertNumber pattern="R$ #,###,##0.00" />
				</h:outputText>	
			</h:panelGrid>
		
			<div style="padding-top:10px;">
				<p:dataTable id="tableServicosOs" value="#{agendamentoBean.currentOrdemServico.servicosOS}" rowIndexVar="rowIndex" 
					widgetVar="tableAgendaVar" var="agenda" rowKey="#{agenda.hora}" style="width:570px;">
					
					<p:ajax event="rowSelectRadio" listener="#{agendamentoBean.onSelectRow}" oncomplete="tableAgendaVar.unselectAllRows();" />
<!--  					<p:ajax event="rowUnselect" listener="#{agendamentoBean.onRowUnselect}" /> -->
										
 					<p:column headerText="Horário" width="50" style="text-align:center;">
 						<h:outputText value="#{agenda.hora.getTime()}"> 
 							<f:convertDateTime pattern="HH:mm" locale="pt" timeZone="America/Sao_Paulo"/> 
						</h:outputText>
 					</p:column>

 					<p:column headerText="Serviço">
 						<h:outputText value="#{of:abbreviate(agenda.servico.descricao, 35)}"/>
 					</p:column>
 					
 					<p:column headerText="Funcionário">
 						<h:outputText value="#{of:abbreviate(agenda.funcionario.nome, 35)}"/>
 					</p:column>

 				</p:dataTable>
			</div>
			
			<div id="popup-buttons" style="padding-right: 32px; padding-top: 10px; text-align: right;">				
				<p:commandButton action="#{agendamentoBean.goToOrdemServico}" value="Finalizar" title="Finalizar"/>			
			</div>
			
			
		</div>
	</h:form>
</p:dialog>